package com.cooper.scraper.show;

import com.cooper.android.comm.Resource;
import com.cooper.scraper.R;

import android.content.Context;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.widget.Gallery;

public abstract class GalleryFanartShowBuilder<T extends Resource> extends
		FanartsShowBuilder<T> {

	// protected FanartImgStrategy fanartImgStrategy;

	private static final int GALLERY_HEIGHT = 440; // pix

	private int heigth;
	private int width;
	protected Context context;

	public GalleryFanartShowBuilder(Context context, WindowManager windownManager,
			int holderHeight) {
		super();
		this.context = context;
		int maxHeight = windownManager.getDefaultDisplay().getHeight()
				- holderHeight;

		heigth = Math.min(GALLERY_HEIGHT, maxHeight);
		width = windownManager.getDefaultDisplay().getWidth();
	}


	@Override
	public void buildAdapterView() {
		if (fanartsShowView != null){
			fanartsShowView.removeFrom();
		}
		fanartsShowView = new FlowGalleryShowView<T>(context,heigth); 
	}

	@Override
	public void buildFanartImgStrategy() {
		fanartViewStrategy.setFanartImgStrategy(new LightFanartImgStragety(
				getFanartWHScale(), 1f, heigth));
		fanartViewStrategy.setViewLayoutParams(new Gallery.LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
		fanartViewStrategy.setWatingImagRes(R.drawable.missing);
		fanartViewStrategy.init(width
				/ (int) fanartViewStrategy.getFanartImgStrategy()
						.getFanartWidth() + 4);
	}


}
